/* 
 * File:   GamestateFree.cpp
 * Author: Pie
 * 
 * Created on April 13, 2011, 6:53 PM
 */

#include "../TextureManager.h"


#include "GamestateManager.h"

#include "GamestateFree.h"
#include "../GameData.h"
#include "../camera/Camera.h"
#include "../GameRenderer.h"
#include "../gui/GuiManager.h"
#include "../gui/GuiWidget.h"
#include "../gui/GuiLabel.h"
#include "../gui/FontManager.h"
#include "../object/SceneManager.h"

GamestateFree::GamestateFree(GameData* data) : Gamestate(data) {
    //GuiProp* gp = new GuiProp();
}


GamestateFree::~GamestateFree() {
}

void GamestateFree::input(SDL_Event* evt, unsigned int ms) {
    if (evt->type == SDL_KEYDOWN) {
        switch (evt->key.keysym.sym) {
            case SDLK_ESCAPE:
                //_data->state_manager()->push_state("main_menu");
                _data->set_run_code(1);
                break;
            default:
                break;
        }
    }
    //gui.input
    //model.input
    _data->camera()->input(evt, ms);
    //player.input
}


void GamestateFree::update(unsigned int ms) {
    _data->camera()->update(ms);
    _data->gui()->update(ms);
    //player.update

}
void GamestateFree::draw() {
    _data->renderer()->draw();
    _data->gui()->draw();
    
}

void GamestateFree::begin() {
    _data->camera()->set_mode("fly");
    SDL_ShowCursor(SDL_DISABLE);
    SDL_WM_GrabInput(SDL_GRAB_ON);

//    GuiProp* gp = new GuiProp();
//    gp->color[0] = 0.7f;
//    gp->color[1] = 0.2f;
//    gp->color[2] = 0.5f;
//    gp->bg_color[2] = 0.0f;
//    gp->zindex = 10.0f;
//    GuiWidget* blah = new GuiLabel("Cha mp ag ne is a d rug th at spec i fie s p ee rs", new GuiRect(200, 200, 100, 100), gp);
//           // _data->texture_manager()->get_texture("data/textures/gent_skel.png", GL_NEAREST));
//
//    _data->gui()->add_widget(blah);

}
void GamestateFree::pause() {

}
void GamestateFree::resume() {
    _data->camera()->set_mode("fly");
    SDL_ShowCursor(SDL_DISABLE);
    SDL_WM_GrabInput(SDL_GRAB_ON);
}
void GamestateFree::die() {

}